<?php

function reequipment_adminapi_createrelrelfrequency($args)
{
    extract($args);

    // Argument check - make sure that all required arguments are present,
    // if not then set an appropriate error message and return
    $invalid = array();

    if (!isset($equipment_id) || !is_int($equipment_id)) {
        $invalid[] = 'equipment_id';
    } 
    if (!isset($company_id) || !is_int($company_id)) {
        $invalid[] = 'company_id';
    } 
    if (!isset($frequency_id) || !is_int($frequency_id)) {
        $invalid[] = 'frequency_id';
    } 
    if (!isset($schedule_id) || !is_int($schedule_id)) {
        $invalid[] = 'schedule_id';
    } 
    if (count($invalid) > 0) {
        $msg = xarML('Invalid #(1)', join(', ', $invalid));
        xarErrorSet(XAR_SYSTEM_EXCEPTION, 'BAD_PARAM', new SystemException($msg));
        return;
    } 
   
    /* Fields in table.
        equipment_id
        frequency_id
        company_id
        schedule_id
   */
   
   	
    // Get datbase setup
    $dbconn =& xarDBGetConn();
    $xartable =& xarDBGetTables();
    $table = $xartable['rel_frequency'];

    // Add item
    $query = "INSERT INTO $table ("
        . "         equipment_id,
        			frequency_id,
        			company_id,
        			schedule_id)"
        . " VALUES (?, ?, ?, ?)";
    $result =& $dbconn->Execute($query, array($equipment_id, $frequency_id, $company_id, $schedule_id));
    if (!$result) return;

    return true;
}
?>